/*
 * @Author: ailin
 * @Date: 2023-07-25 10:47:37
 * @LastEditors: ailin
 * @LastEditTime: 2023-07-25 15:10:32
 * @Description: file content
 * @FilePath: /pay_platform/src/assets/js/DES.js
 */
import cryptoJs from "crypto-js"

/**
 * AES 加密
 * @param message: 需要加密的文本
 * KEY: // 需要前后端保持一致
 * mode: ECB // 需要前后端保持一致
 * pad: Pkcs7 //前端 Pkcs7 对应 后端 Pkcs5
 */
const key = cryptoJs.enc.Latin1.parse("aZcdule123456782")
const iv = cryptoJs.enc.Latin1.parse("0z234567ulebcde7")

export const encrypted = (word) => {
  let enc = cryptoJs.AES.encrypt(word, key, {
    iv: iv,
    mode: cryptoJs.mode.CBC,
    padding: cryptoJs.pad.Pkcs7
  })
  let enced = enc.toString()
  return enced || word
}

// export const desDecrypt=()=> {
//   var key = cryptoJs.enc.Utf8.parse(desKey),
//       iv = cryptoJs.enc.Utf8.parse(desIv),
//       srcs = encryptedData,
//       // CBC 加密模式，Pkcs7 填充方式
//       decrypted = cryptoJs.DES.decrypt(srcs, key, {
//           iv: iv,
//           mode: cryptoJs.mode.CBC,
//           padding: cryptoJs.pad.Pkcs7
//       });
//   return decrypted.toString(cryptoJs.enc.Utf8);
// }
